<?php

class Cpagina extends CI_Model {
    
    
    
    
function get_all_pagina_com_paginacao($inicial,$numreg){
        
        if(!is_numeric($inicial)){
            $inicial=0;
        }
        if(!is_numeric($numreg)){
            $numreg=0;
        }  
        $query = $this->db->query('SELECT * FROM mov_paginas where pag_id_fk = "0" order by pag_id LIMIT '.$inicial.', '.$numreg);
        return $query->result();  
}     
  
function get_all_paginas(){
        
        $query = $this->db->query("SELECT * FROM mov_paginas order by pag_posicao desc");
        return $query->result();  
}     

function get_all_pagina_fk_1(){
        
        $query = $this->db->query("SELECT * FROM mov_paginas where pag_id_fk = '1' order by pag_posicao");
        return $query->result();  
}   

function get_all_pagina_fk_2(){
        
        $query = $this->db->query("SELECT * FROM mov_paginas where pag_id_fk = '2' order by pag_posicao");
        return $query->result();  
} 

function get_all_pagina_fk_3(){
        
        $query = $this->db->query("SELECT * FROM mov_paginas where pag_id_fk = '3' order by pag_posicao");
        return $query->result();  
} 

function get_all_pagina_fk_4(){
        
        $query = $this->db->query("SELECT * FROM mov_paginas where pag_id_fk = '4' order by pag_posicao");
        return $query->result();  
} 

function get_all_pagina_fk_5(){
        
        $query = $this->db->query("SELECT * FROM mov_paginas where pag_id_fk = '5' order by pag_posicao");
        return $query->result();  
} 

function get_all_pagina_fk_6(){
        
        $query = $this->db->query("SELECT * FROM mov_paginas where pag_id_fk = '6' order by pag_posicao");
        return $query->result();  
} 

function conta_registro_pagina(){

        $query = $this->db->get_where('mov_paginas', array('pag_id_fk' => '0'));
        return $query->num_rows();
}
    
function solicita_dados_da_pagina($id){
        
        if(!is_numeric($id)){
            $id=0;
        }
        $query = $this->db->query('SELECT * FROM mov_paginas where pag_id ='.$id);
        return $query->result();  
}   
    
function salva_edicao_pagina($id,$pag){
          
        $this->db->update('mov_paginas',$pag,array('pag_id' => $id));
        return 1;   
}
        
function get_all_itens_pagina($id){
        
        if(!is_numeric($id)){
            $id=0;
        }
        $query = $this->db->query('SELECT * FROM mov_paginas where pag_id_fk ='.$id);
        return $query->result();  
}      
function solicita_dados_do_iten($id){
        
        if(!is_numeric($id)){
            $id=0;
        }
        $query = $this->db->query('SELECT * FROM mov_paginas where pag_id ='.$id);
        return $query->result();  
}   
        
function retorna_nome_da_img($id){
              
        $this->db->select('pag_img');
        $query = $this->db->get_where('mov_paginas', array('pag_id' => $id));
        return $query->result();
}  
  
    
    
    

}